from Constants import *
from myro import *

class Readings:
    def __init__(self):
        self.clear()
    
    def takeReading(self):
        temp=getObstacle()
        for i in xrange(3):
            del self.readings[i][0]
            self.readings[i].append(temp[i]) 
        a=map(lambda x:sum(x)/10, self.readings)
        a[0]*=2
        a[2]*=2
        if a[0]>a[2]:
            self.direction=1
        else:
            self.direction=-1
        return max(a)            
    def clear(self):
        self.readings=map(list,zip(*[getObstacle() for _ in xrange(10)])) 
        self.direction=0
    
